/**
 * Created by ayu on 2017/6/24.
 */
let sqlExcute = require ('../utils/DB/MysqlStatement');
module.exports = {
    saveAccessToken: function ( param, callBack )
    {
        let sql = 'REPLACE INTO wechat_access_token (id, access_token, expires_in) values(1, ?, ?)';
        let arr = [ param[ 0 ], param[ 1 ] ];
        sqlExcute.sqlStatement ([ sql, arr ], function ( done )
        {
            if (done.isSuccess)
            {
                callBack ({
                    isSuccess: true
                });
            }
            else
            {
                callBack ({
                    isSuccess: false
                });
            }
        });
    },
    findAccessToekn: function ( callBack )
    {
        let sql = 'SELECT * FROM wechat_access_token where id = ?';
        let arr = [ 1 ];
        sqlExcute.sqlStatement ([ sql, arr ], function ( done )
        {
            if (done.isSuccess)
            {
                callBack ({
                    isSuccess: true,
                    result   : done.result
                });
            }
            else
            {
                callBack ({
                    isSuccess: false
                });
            }
        });
    }
};